package com.lzw.breezeNovel.webApp.mapper.video;

import com.lzw.breezeNovel.model.entity.pojo.user.UserInfo;
import com.lzw.breezeNovel.model.entity.pojo.video.ShortVideo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.mapper.video
 * @date 2025/3/23
 * @description 短视频
 */
@Mapper
@SuppressWarnings("all")
public interface ShortVideoMapper {

    /**
     * 插入短视频
     * @param shortVideo
     */
    void insert(ShortVideo shortVideo);

    /**
     * 获取所有短视频
     *
     * @param start
     * @param size
     * @param userId
     * @return
     */
    List<ShortVideo> getAllShortVideo(Integer start, Integer size, Long userId);

    /**
     * 更新点赞数
     * @param shortId
     */
    @Update("update short_video set like_count = like_count + 1 where short_video_id = #{shortId} ")
    void updateLikeCount(Long shortId);

    /**
     * 更新点赞数
     * @param shortId
     */
    @Update("update short_video set like_count = like_count - 1 where short_video_id = #{shortId} ")
    void updateLikeCountReduce(Long shortId);

    /**
     * 更新分享数
     * @param videoId
     * @param shareCount
     */
    @Update("update short_video set share = #{shareCount} where short_video_id = #{videoId} ")
    void updateShareCount(Long videoId, Integer shareCount);

    /**
     * 查询用户信息
     * @param shortId
     * @return
     */
    UserInfo selectUserInfo(Long shortId);

    /**
     * 更新播放次数
     * @param videoId
     */
    @Update("update short_video set play_count = #{playCount} where short_video_id = #{videoId} ")
    void updatePlayCount(Long videoId, Integer playCount);

    /**
     * 获取所有短视频根据用户id
     * @param start
     * @param size
     * @param userId
     * @return
     */
    List<ShortVideo> getAllVideoByUserId(Integer start, Integer size, Long userId);

    /**
     * 获取短视频根据用户id
     * @return
     */
    @Select("select like_count from short_video where short_video_id = #{videoId}")
    ShortVideo selectVidoe(Long videoId);

    /**
     * 根据id删除短视频
     * @param videoId
     * @param userId
     */
    @Delete("delete from short_video where short_video_id = #{videoId} and user_id = #{userId}")
    void deleteShortVideo(Long videoId, Long userId);
}
